<?php

namespace SidToken\Model;


use Think\Model;

/**
 * 任务中心模块
 * Class QueueModel
 * @package TaskCenter\Model
 */
class QueueModel extends Model
{
    const STATUS_WAIT = 0;
    const STATUS_NORMAL = 1;

    /**
     * @param $mo
     * @param $rs
     * @param $controller_url
     * @param $parameter
     * @param null $stime
     * @return array
     */
    public function addQueue($mo, $rs, $controller_url, $parameter, $stime = null)
    {
        $data = array(
            'controller_url' => $controller_url,
            'parameter' => json_encode($parameter),
            'ctime' => time(),
            'etime' => 0,
            'stime' => $stime ? $stime : time(),//开始时间
            'status' => self::STATUS_WAIT
        );
        $rs[] = $mo->table("ocenter_queue")->add($data);
        return $rs;
    }

}